﻿$(function () {
    $(".headerR li:first").addClass("active");
    $(".boxMenuL").each(function () {
        $(this).hover(function () {
            var appendObj = $("#" + $(this).attr("rel"));
            var boundObj = $(this);
            toogleMenu($(boundObj), $(appendObj));
        }, function () { })
    })
    $(".leftMenu").each(function () {
        var obj = $(this);
        $(this).hover(function () {
        }, function () {
            $.wait(function () {
                $(obj).hide();
                $(obj).parent().css({ "margin-bottom": "0px" });
                $(obj).prev().removeClass("active");
            }, 3);
        })
    })
    $(".bodyL input[type=hidden]").val("");
})

function toogleMenu(boundObj, appendObj) {
    var heAppendObj = $(appendObj).height();
    var curMenuL = $(boundObj).parent();
    $(".boxMenuL").not($(boundObj)).removeClass("active");
    $(boundObj).addClass("active");

    $(".menuL").not($(curMenuL)).css({ "margin-bottom": "0px" });
    $(curMenuL).css({ "margin-bottom": heAppendObj + "px" });
    $(".leftMenu").not($(appendObj)).hide(function () { })
    $(appendObj).show();
    $(boundObj).after(appendObj);
}
function selectCriteria(obj, criteria, objHidden) {
    $(objHidden).val(criteria);
    var liObj = $(obj).parent();
    $(obj).next().show();
    $(liObj).siblings().hide();
    //var pageIndex = $("input[id*=hidPageIndex]").val();
    $(".b120x120").each(function () {
        var loaiID = $(this).attr("boundid");
        doLoad(loaiID,1);
    })
   
}

function delCriteria(obj, objHidden) {
    $(objHidden).val("");
    var ulObj = $(obj).parents("ul");
    $(".lnkDel", $(ulObj)).hide();
    $("li", $(ulObj)).show();
    //var pageIndex = $("input[id*=hidPageIndex]").val();
    $(".b120x120").each(function () {
        var loaiID = $(this).attr("boundid");
        doLoad(loaiID, 1);
    })
}
function doLoad(loaiID,pageIndex) {
    var quanHuyenID = $("input[id*=hidQuanHuyen]").val();
    if (quanHuyenID == '') {
        quanHuyenID = 42;
    }
    $("div[boundid="+loaiID+"]").html("");
    $("#loading").show();
    $.get("/template/duankhudothi.aspx", { loaiDAID: loaiID, quanHuyenID: quanHuyenID, page: pageIndex }, function (data) {
        $("#loading").hide();
        $("div[boundid=" + loaiID + "]").html(data);
    });
    $("div[boundid=" + loaiID + "]").ajaxComplete(function () {
        if ($(".boxss").size() == 0)
            $("div[boundid=" + loaiID + "]").html("<br/><b>Không có kết quả phù hợp</b><br/><br/>");
    })

}